package com.example.hxds.mps.controller;

import com.example.hxds.common.util.R;
import com.example.hxds.mps.controller.form.CalculateDriveLineForm;
import com.example.hxds.mps.controller.form.EstimateOrderMileageAndMinuteForm;
import com.example.hxds.mps.service.MapService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.HashMap;

/**
 * @author 86166
 * @description :
            * @date 2024/1/179:59
            */
            @RestController
            @RequestMapping("/map")
            @Tag(name = "MapController",description = "地图Web接口")
    public class MapController {

        @Resource
        private MapService mapService;

        @PostMapping("/estimateOrderMileageAndMinute")
        @Operation(summary = "估算里程和时间")
        public R estimateOrderMileageAndMinute(@RequestBody @Valid EstimateOrderMileageAndMinuteForm form){
            HashMap map = mapService.estimateOrderMileageAndMinute(form.getMode(), form.getStartPlaceLatitude(), form.getStartPlaceLongitude(), form.getEndPlaceLatitude(), form.getEndPlaceLongitude());
            return R.ok().put("result",map);
        }


        @PostMapping("/calculateDriverLine")
        @Operation(summary = "计算行驶路线")
    public R calculateDriverLine(@RequestBody @Valid CalculateDriveLineForm form){
        HashMap map = mapService.calculateDriveLine(form.getStartPlaceLatitude(), form.getStartPlaceLongitude(), form.getEndPlaceLatitude(), form.getEndPlaceLongitude());
        return R.ok().put("result",map);
    }

}
